<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="理单日期" prop="processingDate">
        <el-date-picker
          clearable
          v-model="queryParams.processingDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择理单日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="下单编号" prop="orderNumber">
        <el-input
          v-model="queryParams.orderNumber"
          placeholder="请输入下单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="下单款号" prop="orderItemNumber">
          <el-input
            v-model="queryParams.orderItemNumber"
            placeholder="请输入下单款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="所属类别" prop="category">
          <el-input
            v-model="queryParams.category"
            placeholder="请输入所属类别"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="设计款号" prop="designNumber">
          <el-input
            v-model="queryParams.designNumber"
            placeholder="请输入设计款号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="执行进度" prop="executionProgress">
          <el-input
            v-model="queryParams.executionProgress"
            placeholder="请输入执行进度"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="理单编号" prop="processingNumber">
          <el-input
            v-model="queryParams.processingNumber"
            placeholder="请输入理单编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="加工合同号" prop="processingContractNumber">
          <el-input
            v-model="queryParams.processingContractNumber"
            placeholder="请输入加工合同号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item label="工厂交期" prop="factoryDeliveryDate">
          <el-date-picker
            clearable
            v-model="queryParams.factoryDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择工厂交期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划天数" prop="plannedDays">
          <el-input
            v-model="queryParams.plannedDays"
            placeholder="请输入计划天数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="颜色" prop="colorProperty">
          <el-input
            v-model="queryParams.colorProperty"
            placeholder="请输入颜色"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input
            v-model="queryParams.quantity"
            placeholder="请输入数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="物料时间" prop="materialTime">
          <el-date-picker
            clearable
            v-model="queryParams.materialTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择物料时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="需要裁剪" prop="cuttingNeeded">
          <el-input
            v-model="queryParams.cuttingNeeded"
            placeholder="请输入需要裁剪"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="裁剪日期" prop="cuttingDate">
          <el-date-picker
            clearable
            v-model="queryParams.cuttingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择裁剪日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="外发" prop="outsourcing">
          <el-input
            v-model="queryParams.outsourcing"
            placeholder="请输入外发"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="入库日期" prop="storageDate">
          <el-date-picker
            clearable
            v-model="queryParams.storageDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入库日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际天数" prop="actualDays">
          <el-input
            v-model="queryParams.actualDays"
            placeholder="请输入实际天数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="延期天数" prop="extensionDays">
          <el-input
            v-model="queryParams.extensionDays"
            placeholder="请输入延期天数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="结案" prop="caseClosure">
          <el-input
            v-model="queryParams.caseClosure"
            placeholder="请输入结案"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="结案时间" prop="caseClosureDate">
          <el-date-picker
            clearable
            v-model="queryParams.caseClosureDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择结案时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产前会议" prop="preproductionMeeting">
          <el-input
            v-model="queryParams.preproductionMeeting"
            placeholder="请输入产前会议"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="会议时间" prop="meetingTime">
          <el-date-picker
            clearable
            v-model="queryParams.meetingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择会议时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产前结论" prop="preproductionConclusion">
          <el-input
            v-model="queryParams.preproductionConclusion"
            placeholder="请输入产前结论"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="客户简称" prop="customerAbbreviation">
          <el-input
            v-model="queryParams.customerAbbreviation"
            placeholder="请输入客户简称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input
            v-model="queryParams.brand"
            placeholder="请输入品牌"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="业务员" prop="salesperson">
          <el-input
            v-model="queryParams.salesperson"
            placeholder="请输入业务员"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="理单人" prop="liaisonPerson">
          <el-input
            v-model="queryParams.liaisonPerson"
            placeholder="请输入理单人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="部门" prop="department">
          <el-input
            v-model="queryParams.department"
            placeholder="请输入部门"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="制单日期" prop="orderRaisingDate">
          <el-date-picker
            clearable
            v-model="queryParams.orderRaisingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择制单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="公司抬头" prop="companyName">
          <el-input
            v-model="queryParams.companyName"
            placeholder="请输入公司抬头"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="最后修改人" prop="lastModifier">
          <el-input
            v-model="queryParams.lastModifier"
            placeholder="请输入最后修改人"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="最后修改时间" prop="lastModificationTime">
          <el-date-picker
            clearable
            v-model="queryParams.lastModificationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后修改时间"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['purchase:PurchaseTallySheet:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['purchase:PurchaseTallySheet:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['purchase:PurchaseTallySheet:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['purchase:PurchaseTallySheet:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-upload" @click="daoru"
          >导入</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="PurchaseTallySheetList"
      @selection-change="handleSelectionChange"
      :height="600"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column width="120" label="id" align="center" prop="id" />
      <el-table-column
        width="120"
        label="加工合同号"
        align="center"
        prop="processingContractNumber"
      />
      <el-table-column
        width="120"
        label="订单类型"
        align="center"
        prop="orderType"
      />
      <!-- <el-table-column
        width="120"
        label="下单编号"
        align="center"
        prop="orderNumber"
      />
      <el-table-column width="120" label="主图" align="center" prop="mainImage">
        <template #default="scope">
          <el-popover
            effect="light"
            trigger="click"
            placement="right"
            width="auto"
            v-if="scope.row.mainImage"
          >
            <template #default>
              <img
                :src="pjtUrl + scope.row.mainImage"
                style="width: 800px; height: 600px; object-fit: contain"
                lazy
              />
            </template>
            <template #reference>
              <img
                :src="pjtUrl + scope.row.mainImage"
                style="object-fit: contain; width: 40px; height: 40px"
                lazy
              />
            </template>
          </el-popover>
        </template>
        
      </el-table-column>
      <el-table-column width="120" label="状态" align="center" prop="status" />
      <el-table-column
        width="120"
        label="下单款号"
        align="center"
        prop="orderItemNumber"
      />
      <el-table-column
        width="120"
        label="所属类别"
        align="center"
        prop="category"
      />
      <el-table-column
        width="120"
        label="设计款号"
        align="center"
        prop="designNumber"
      />
      <el-table-column
        width="120"
        label="执行进度"
        align="center"
        prop="executionProgress"
      />
      <el-table-column
        width="120"
        label="理单编号"
        align="center"
        prop="processingNumber"
      />

      <el-table-column
        width="120"
        label="理单日期"
        align="center"
        prop="processingDate"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.processingDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="工厂交期"
        align="center"
        prop="factoryDeliveryDate"
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.factoryDeliveryDate, "{y}-{m}-{d}")
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="计划天数"
        align="center"
        prop="plannedDays"
      />
      <el-table-column
        width="120"
        label="颜色"
        align="center"
        prop="colorProperty"
      >
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="bottom" width="300">
            
            <el-input
              v-model="scope.row.colorProperty"
              :min-height="192"
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 24 }"
              :style="{ width: '100%' }"
              :disabled="true"
            />
            <div slot="reference">
              <span class="textname">
                {{ scope.row.colorProperty }}
              </span>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        width="120"
        label="数量"
        align="center"
        prop="quantity"
      />
      <el-table-column
        width="120"
        label="物料确认"
        align="center"
        prop="materialConfirmation"
      />
      <el-table-column
        width="120"
        label="物料时间"
        align="center"
        prop="materialTime"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.materialTime, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="需要裁剪"
        align="center"
        prop="cuttingNeeded"
      />
      <el-table-column
        width="120"
        label="裁剪日期"
        align="center"
        prop="cuttingDate"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.cuttingDate, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="外发"
        align="center"
        prop="outsourcing"
      />
      <el-table-column
        width="120"
        label="入库日期"
        align="center"
        prop="storageDate"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.storageDate, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="实际天数"
        align="center"
        prop="actualDays"
      />
      <el-table-column
        width="120"
        label="延期天数"
        align="center"
        prop="extensionDays"
      />
      <el-table-column
        width="120"
        label="结案"
        align="center"
        prop="caseClosure"
      />
      <el-table-column
        width="120"
        label="结案时间"
        align="center"
        prop="caseClosureDate"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.caseClosureDate, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="产前会议"
        align="center"
        prop="preproductionMeeting"
      />
      <el-table-column
        width="120"
        label="会议时间"
        align="center"
        prop="meetingTime"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.meetingTime, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="产前结论"
        align="center"
        prop="preproductionConclusion"
      />

      <el-table-column
        width="120"
        label="采购类型"
        align="center"
        prop="purchaseType"
      />
      <el-table-column
        width="120"
        label="客户简称"
        align="center"
        prop="customerAbbreviation"
      />
      <el-table-column width="120" label="品牌" align="center" prop="brand" />
      <el-table-column
        width="120"
        label="业务员"
        align="center"
        prop="salesperson"
      />
      <el-table-column
        width="120"
        label="理单人"
        align="center"
        prop="liaisonPerson"
      />
      <el-table-column
        width="120"
        label="部门"
        align="center"
        prop="department"
      />
      <el-table-column
        width="120"
        label="制单日期"
        align="center"
        prop="orderRaisingDate"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.orderRaisingDate, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column>
      <el-table-column
        width="120"
        label="公司抬头"
        align="center"
        prop="companyName"
      />
      <el-table-column
        width="120"
        label="最后修改人"
        align="center"
        prop="lastModifier"
      />
      <el-table-column
        width="120"
        label="最后修改时间"
        align="center"
        prop="lastModificationTime"
      >
        <template slot-scope="scope">
  <span>{{ parseTime(scope.row.lastModificationTime, "{y}-{m}-{d}") }}</span>
</template>
      </el-table-column> -->
      <el-table-column
        width="120"
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['purchase:PurchaseTallySheet:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['purchase:PurchaseTallySheet:remove']"
            >删除</el-button
          >
        </template></el-table-column
      >
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改理单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="加工合同号" prop="processingContractNumber">
          <el-input
            v-model="form.processingContractNumber"
            placeholder="请输入加工合同号"
          />
        </el-form-item>
        <el-form-item label="订单类型" prop="orderType">
          <el-input v-model="form.orderType" placeholder="订单类型" />
        </el-form-item>

        <!-- <el-form-item label="下单编号" prop="orderNumber">
          <el-input v-model="form.orderNumber" placeholder="请输入下单编号" />
        </el-form-item>
        <el-form-item label="主图" prop="mainImage">
          <image-upload v-model="form.mainImage" />
        </el-form-item>
        <el-form-item label="下单款号" prop="orderItemNumber">
          <el-input
            v-model="form.orderItemNumber"
            placeholder="请输入下单款号"
          />
        </el-form-item>
        <el-form-item label="所属类别" prop="category">
          <el-input v-model="form.category" placeholder="请输入所属类别" />
        </el-form-item>
        <el-form-item label="设计款号" prop="designNumber">
          <el-input v-model="form.designNumber" placeholder="请输入设计款号" />
        </el-form-item>
        <el-form-item label="执行进度" prop="executionProgress">
          <el-input
            v-model="form.executionProgress"
            placeholder="请输入执行进度"
          />
        </el-form-item>
        <el-form-item label="理单编号" prop="processingNumber">
          <el-input
            v-model="form.processingNumber"
            placeholder="请输入理单编号"
          />
        </el-form-item>
        
        <el-form-item label="理单日期" prop="processingDate">
          <el-date-picker
            clearable
            v-model="form.processingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择理单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="工厂交期" prop="factoryDeliveryDate">
          <el-date-picker
            clearable
            v-model="form.factoryDeliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择工厂交期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划天数" prop="plannedDays">
          <el-input v-model="form.plannedDays" placeholder="请输入计划天数" />
        </el-form-item>
        <el-form-item label="颜色" prop="colorProperty">
          <el-input v-model="form.colorProperty" placeholder="请输入颜色" />
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input v-model="form.quantity" placeholder="请输入数量" />
        </el-form-item>
        <el-form-item label="物料确认" prop="materialConfirmation">
          <el-input
            v-model="form.materialConfirmation"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="物料时间" prop="materialTime">
          <el-date-picker
            clearable
            v-model="form.materialTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择物料时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="需要裁剪" prop="cuttingNeeded">
          <el-input v-model="form.cuttingNeeded" placeholder="请输入需要裁剪" />
        </el-form-item>
        <el-form-item label="裁剪日期" prop="cuttingDate">
          <el-date-picker
            clearable
            v-model="form.cuttingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择裁剪日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="外发" prop="outsourcing">
          <el-input v-model="form.outsourcing" placeholder="请输入外发" />
        </el-form-item>
        <el-form-item label="入库日期" prop="storageDate">
          <el-date-picker
            clearable
            v-model="form.storageDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入库日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际天数" prop="actualDays">
          <el-input v-model="form.actualDays" placeholder="请输入实际天数" />
        </el-form-item>
        <el-form-item label="延期天数" prop="extensionDays">
          <el-input v-model="form.extensionDays" placeholder="请输入延期天数" />
        </el-form-item>
        <el-form-item label="结案" prop="caseClosure">
          <el-input v-model="form.caseClosure" placeholder="请输入结案" />
        </el-form-item>
        <el-form-item label="结案时间" prop="caseClosureDate">
          <el-date-picker
            clearable
            v-model="form.caseClosureDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择结案时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产前会议" prop="preproductionMeeting">
          <el-input
            v-model="form.preproductionMeeting"
            placeholder="请输入产前会议"
          />
        </el-form-item>
        <el-form-item label="会议时间" prop="meetingTime">
          <el-date-picker
            clearable
            v-model="form.meetingTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择会议时间"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="产前结论" prop="preproductionConclusion">
          <el-input
            v-model="form.preproductionConclusion"
            placeholder="请输入产前结论"
          />
        </el-form-item>
        <el-form-item label="客户简称" prop="customerAbbreviation">
          <el-input
            v-model="form.customerAbbreviation"
            placeholder="请输入客户简称"
          />
        </el-form-item>
        <el-form-item label="品牌" prop="brand">
          <el-input v-model="form.brand" placeholder="请输入品牌" />
        </el-form-item>
        <el-form-item label="业务员" prop="salesperson">
          <el-input v-model="form.salesperson" placeholder="请输入业务员" />
        </el-form-item>
        <el-form-item label="理单人" prop="liaisonPerson">
          <el-input v-model="form.liaisonPerson" placeholder="请输入理单人" />
        </el-form-item>
        <el-form-item label="部门" prop="department">
          <el-input v-model="form.department" placeholder="请输入部门" />
        </el-form-item>
        <el-form-item label="制单日期" prop="orderRaisingDate">
          <el-date-picker
            clearable
            v-model="form.orderRaisingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择制单日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="公司抬头" prop="companyName">
          <el-input v-model="form.companyName" placeholder="请输入公司抬头" />
        </el-form-item>
        <el-form-item label="最后修改人" prop="lastModifier">
          <el-input
            v-model="form.lastModifier"
            placeholder="请输入最后修改人"
          />
        </el-form-item>
        <el-form-item label="最后修改时间" prop="lastModificationTime">
          <el-date-picker
            clearable
            v-model="form.lastModificationTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择最后修改时间"
          >
          </el-date-picker>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改产品二级信息对话框 :on-change="handleChange"-->
    <el-dialog
      :title="title"
      :visible.sync="dialogVisible"
      width="500px"
      append-to-body
      v-if="dialogVisible"
    >
      <el-upload
        :action="Upload.url"
        :headers="Upload.headers"
        :limit="limit"
        :on-exceed="handleExceed"
        :on-success="handlePictureSuccessPic"
        :before-upload="beforeAvatarUpload"
        :on-preview="handlePictureCardPreview"
        :file-list="fileLi"
        :on-change="changeFile1"
      >
        <el-button size="small" type="primary">导入文件</el-button>
        <!-- <i class="el-icon-plus"></i> -->
      </el-upload>
    </el-dialog>
  </div>
</template>

<script>
import {
  listPurchaseTallySheet,
  getPurchaseTallySheet,
  delPurchaseTallySheet,
  addPurchaseTallySheet,
  updatePurchaseTallySheet,
} from "@/api/purchase/PurchaseTallySheet";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "PurchaseTallySheet",
  data() {
    return {
      // pjtUrl: process.env.VUE_APP_BASE_API,
      pjtUrl: process.env.VUE_APP_BASE_API,

      fileLi: [],
      file: "",
      dialogVisible: false,
      // 图片数量限制
      limit: 2,
      Upload: {
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken(),
        },
        // 图片上传的方法地址:
        url:
          process.env.VUE_APP_BASE_API +
          "/purchase/PurchaseTallySheet/importData",
      },
      isOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 理单表格数据
      PurchaseTallySheetList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNumber: null,
        mainImage: null,
        status: null,
        orderItemNumber: null,
        category: null,
        designNumber: null,
        executionProgress: null,
        processingNumber: null,
        processingContractNumber: null,
        processingDate: null,
        factoryDeliveryDate: null,
        plannedDays: null,
        colorProperty: null,
        quantity: null,
        materialConfirmation: null,
        materialTime: null,
        cuttingNeeded: null,
        cuttingDate: null,
        outsourcing: null,
        storageDate: null,
        actualDays: null,
        extensionDays: null,
        caseClosure: null,
        caseClosureDate: null,
        preproductionMeeting: null,
        meetingTime: null,
        preproductionConclusion: null,
        orderType: null,
        purchaseType: null,
        customerAbbreviation: null,
        brand: null,
        salesperson: null,
        liaisonPerson: null,
        department: null,
        orderRaisingDate: null,
        companyName: null,
        lastModifier: null,
        lastModificationTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询理单列表 */
    getList() {
      this.loading = true;
      listPurchaseTallySheet(this.queryParams).then((response) => {
        this.PurchaseTallySheetList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderNumber: null,
        mainImage: null,
        status: null,
        orderItemNumber: null,
        category: null,
        designNumber: null,
        executionProgress: null,
        processingNumber: null,
        processingContractNumber: null,
        processingDate: null,
        factoryDeliveryDate: null,
        plannedDays: null,
        colorProperty: null,
        quantity: null,
        materialConfirmation: null,
        materialTime: null,
        cuttingNeeded: null,
        cuttingDate: null,
        outsourcing: null,
        storageDate: null,
        actualDays: null,
        extensionDays: null,
        caseClosure: null,
        caseClosureDate: null,
        preproductionMeeting: null,
        meetingTime: null,
        preproductionConclusion: null,
        orderType: null,
        purchaseType: null,
        customerAbbreviation: null,
        brand: null,
        salesperson: null,
        liaisonPerson: null,
        department: null,
        orderRaisingDate: null,
        companyName: null,
        lastModifier: null,
        lastModificationTime: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {};
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加理单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getPurchaseTallySheet(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改理单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseTallySheet(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseTallySheet(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除理单编号为"' + ids + '"的数据项？')
        .then(function () {
          return delPurchaseTallySheet(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "purchase/PurchaseTallySheet/export",
        {
          ...this.queryParams,
        },
        `PurchaseTallySheet_${new Date().getTime()}.xlsx`
      );
    },
    //部门文件导入修改打开
    daoru() {
      this.dialogVisible = true;
    },
    // 打开加载层
    openUploadLoading() {
      this.$modal.loading("正在导入，请稍候！");
    },
    //文件导入成功回传

    handlePictureSuccessPic(res, file) {
      console.log(JSON.stringify(res));
      //设置图片访问路径 （url 后台传过来的的上传地址）
      // this.picUrl = file.response.url;
      // const url = file.response.fileName;
      this.file = file.response.url;
      console.log(JSON.stringify(this.file));
      if (res.code == 200) {
        this.dialogVisible = false;
        this.$modal.closeLoading();
        this.$modal.msgSuccess(res.msg);
        // if (res.msg == "操作成功") {
        //   this.$modal.msgSuccess("导入成功");
        // } else {
        //   this.$modal.msgError(res.msg);
        // }
        this.getList();
        // return true
      } else {
        this.$modal.msgError(res.msg);
        this.dialogVisible = true;
        // this.$message.msgError('该颜色未在字典定义')
        return;
      }
    },
    //图片预览
    handlePictureCardPreview(file) {
      // this.picUrl = file.url
      // this.imageUrl = file.url;
      // this.dialogVisible = true;
    },
    //图片上传前的相关判断
    beforeAvatarUpload(file) {
      // const isJPG = file.type == 'image/jpeg' || file.type == 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 100;
      // if (!isJPG) {
      //     this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
      // }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 100MB!");
      }
      this.openUploadLoading();
      return isLt2M;
    },

    // 文件个数超出
    handleExceed() {
      this.$modal.msgError(`上传链接文件数量不能超过 ${this.limit} 个!`);
    },
    // 上传文件让第二次覆盖第一的文件
    changeFile1(file, fileList) {
      if (fileList.length > 1) {
        this.fileLi = fileList.slice(-1);

        // this.fileList = [fileList[fileList.length - 1]]//这一步，是 展示最后一次选择文件
      }
      // this.fileSpecial = fileList;
    },
  },
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  height: 70vh;
  overflow-x: hidden;
}

span.textname {
  display: -webkit-box;

  text-overflow: ellipsis;
  overflow: hidden;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

.el-input.is-disabled ::v-deep .el-input__inner {
  color: #606266;
  background-color: #f5f7fa;
  border: none;
}

.el-textarea.is-disabled ::v-deep .el-textarea__inner {
  color: #606266;
  background-color: white;
  border: none;
  width: 500px;
  resize: none;
  cursor: pointer;
}
</style>